package com.jz.community.modulemine.utils;


import android.os.Environment;

import java.io.File;
import java.io.FileInputStream;
import java.io.FileOutputStream;
import java.io.IOException;
import java.nio.channels.FileChannel;

public final class FileUtil
{

    public static void main(String[] args)
    {
        System.out.println(new Float(100.23565522 * 100 + 0.5).longValue());
    }


    public static void fileChannelCopy(File source, File target)
    {
        FileInputStream fi = null;
        FileOutputStream fo = null;
        FileChannel in = null;
        FileChannel out = null;
        try
        {
            fi = new FileInputStream(source);
            fo = new FileOutputStream(target);
            in = fi.getChannel();
            out = fo.getChannel();
            in.transferTo(0, in.size(), out);
        } catch (IOException e)
        {
            e.printStackTrace();
        } finally
        {
            try
            {
                fi.close();
                in.close();
                fo.close();
                out.close();
            } catch (IOException e)
            {
                e.printStackTrace();
            }
        }
    }

    public static boolean checkSDCard()
    {
        boolean sdCardExist = Environment.getExternalStorageState()
                .equals(Environment.MEDIA_MOUNTED);
        return sdCardExist;
    }

    public static boolean exists(String name)
    {
        return exists(new File(name));
    }

    public static boolean exists(File file)
    {
        if (file == null)
        {
            return false;
        }
        return file.exists();
    }
}
